package com.miao.exception;

import com.miao.vo.ResultVo;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;


/**
 * @author: 丰
 * @date: 2023/3/3 11:59
 */
@ControllerAdvice
public class GlobalExceptionAdvice {

//    private static final Logger logger = LoggerFactory.getLogger(GlobalExceptionAdvice.class);

    // 捕获所有运行时异常
    @ExceptionHandler(RuntimeException.class)
    public ResultVo<Object> exceptionHandler(RuntimeException e) {
        System.out.println(e.getMessage());
        return ResultVo.failed(e.getMessage());
    }
}
